<template>
	<view>
		<cu-custom style="height: 0px;" class="navBox" bgColor="bg-gradual-blue" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">所有文档</block>
		</cu-custom>
		
		<view class="flies" v-for="(jtem, j) in entity.listpdf" :key="j">
			<view class="detailFile">
				<img :src="fileSrc" alt="" />
				<view class="fileName">{{jtem.FileName}}</view>
				<view class="seeBtn" @click="lookJtem(jtem.FilePath)">查看</view>
			</view>
		</view>
		
	</view>
</template>

<script>
	import request from '@/common/request.js';
	import unifab from "@/components/beyondGod-drag/beyoundGod-drag.vue";
	//import fileSign from '@/static/filesSign.png'
	export default {
		components:{
			unifab
		},
		data() {
			return {
				entity:{},
				fileSrc: request.baseUrl1+'/Resource/Sg/filesSign.png',
			}
		},
		onShow() {
			
		},
		onLoad(option) {
			let that = this
			that.getDetail(option.WorkId)
		},
		methods: {
			getDetail(id){
				let that=this
				let opts = {
					url: 'WorkflowApi/GetStepSWorkId',
					method: 'get'
				};
				let data = {
					WorkId:id
				}
				uni.showLoading({
					title:'加载中...'
				})
				request.httpTokenRequest(opts,data).then(res=>{
					uni.hideLoading();
					console.log(res.data.Data)
					that.entity = res.data.Data
				})
			},
			
			lookJtem(jtem){
				console.log('jtem',request.baseUrl1+jtem)
				uni.downloadFile({
					url: request.baseUrl1+jtem,
					success(res){
						if (res.statusCode == 200) {
							console.log('下载成功')
							let filePath = encodeURI(res.tempFilePath)
							uni.openDocument({
								filePath: encodeURI(filePath),
								showMenu: true,
								success:function(res){
									console.log('打开文档成功')
								},
								fail(e){
									console.log('打开失败', e)
									uni.showToast({
										title: '文件打开失败',
										icon: 'none'
									})
								}
							})
						} else {
							console.log('下载失败')
							uni.showToast({
								title: '文件下载失败',
								icon: 'none'
							})
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.flies {
		padding: 30rpx 30rpx 0;
		background-color: #fff;
		&:last-child{
			padding-bottom: 30rpx;
		}
		.detailFile{
			display: flex;
			align-items: center;
			justify-content: space-between;
			// margin: 15rpx 0;
			>img{
				$w: 77rpx;
				width: $w;
				height: (200/176)*$w;
			}
			.fileName{
				flex: 1;
				margin: 0 15rpx;
				overflow: hidden;
				text-overflow: ellipsis;
				// 单行
				// white-space: nowrap;
				
				// 多行
				display: -webkit-box;
				-webkit-line-clamp: 2; /* 限制行数 */
				-webkit-box-orient: vertical;
			}
			.seeBtn{
				border-radius: 15rpx;
				padding: 15rpx 25rpx;
				color: #fff;
				background: linear-gradient(45deg,rgba(20,178,181,100%),rgba(43,194,161,100%));
			}
		}
	}
</style>